package com.play.ballen.synthetic.adapter

import android.widget.ImageView
import android.widget.TextView
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.play.ballen.R
import com.play.ballen.pack.entity.PackBallInfo
import com.yuven.appframework.util.imageloader.ImageUtil
import com.yuven.baselib.utils.ResourceUtil

class SyntheticDialogBallAdapter(data: MutableList<PackBallInfo>) :
    BaseQuickAdapter<PackBallInfo, BaseViewHolder>(R.layout.item_synthetic_ball_choose, data) {

    var id1Selected = ""
    var id2Selected = ""
    var id3Selected = ""

    override fun convert(holder: BaseViewHolder, item: PackBallInfo) {

        val imgBall = holder.getView<ImageView>(R.id.imgBall)
        val tvPropertyNo = holder.getView<TextView>(R.id.tvPropertyNo)
        val tvPropertyLevel = holder.getView<TextView>(R.id.tvPropertyLevel)
        val tvPropertySport = holder.getView<TextView>(R.id.tvPropertySport)
        val tvPropertyDate = holder.getView<TextView>(R.id.tvPropertyDate)
        val tvPropertyPlayCount = holder.getView<TextView>(R.id.tvPropertyPlayCount)

        holder.itemView.isSelected =
            item.id == id1Selected || item.id == id2Selected || item.id == id3Selected

        item.run {
            ImageUtil.instance.loadImage(0, 0, pic, imgBall)

            tvPropertyNo.text = ResourceUtil.getString(R.string.synthetic_property_no, no)
            tvPropertyLevel.text = ResourceUtil.getString(R.string.synthetic_property_level, name)
            tvPropertyPlayCount.text =
                ResourceUtil.getString(R.string.synthetic_property_play_count, task_count)
            tvPropertyDate.text = if (day == "0") {
                ResourceUtil.getString(R.string.synthetic_property_date_forever)
            } else {
                ResourceUtil.getString(R.string.synthetic_property_date, day)
            }
            tvPropertySport.text =
                ResourceUtil.getString(R.string.synthetic_property_sport, percent) + "%"
        }
    }

}